package IC.Semantics.types;

import IC.Semantics.SemanticError;

/**
 * describes the base unit for the semantic types used for type checking
 * called semantic type to make difference more coherent with the AST Type class  
 */
public abstract class SemanticType 
{
	// ========================== constants ===========================
	public static final String INT_TYPE_NAME = "int";
	public static final String BOOLEAN_TYPE_NAME = "boolean";
	public static final String VOID_TYPE_NAME = "void";
	public static final String STRING_TYPE_NAME = "string";
	public static final String NULL_TYPE_NAME = "null";

	
	// ================================================================
	
	protected final String name;
	protected int id;
	
	public SemanticType(String name){
		this.name = name;
		this.id= ++TypeTable.idGenerator;
	}
	
	public int getTypeTableID(){
		return this.id;
	}
	
	public String getName(){
		return name;
	}
	
	public String toString(){
		return name;
	}
	
	public abstract boolean subtypeOf(SemanticType t) throws SemanticError;
}
